<template>
  <div>
    <table-ext :columns="columns" :searchForm="searchForm" :config="config" ref="tableExt">
    </table-ext>
  </div>
</template>

<script>
  import TableExt from '@/components/common/table-ext/table-ext.vue';
  import TableIcon from '@/components/common/table-ext/table-icon';
  export default {
    components:{
      'table-ext': TableExt
    },
    data() {
      return {
        test:'',
        userOptions: [{
          value: '-1',
          label: '系统管理员'
        }],
        config:{
          title: '招标', //页面标题
          isPage: true, //是否分页
          isNo: false, //是否显示序号
          selection: false, //是否显示复选框
          crudMapping:{ // CRUD方法
            query:{
              url: this.lib.config.host.bidtender + '/bidmgt/tender/query',
              data:{}
            }
          }
        },
        formLabelWidth: '120px',
        // 查询表单配置
        searchForm:[
          //显示标签 数据字段 标签类型
          {label: '单号', key: 'psNo', type: 'input'},
          {label: '项目名称', key: 'psTitle', type: 'input'}
        ],
        // 表格列定义
        columns:[
          {label: '招标编号',key: 'psNo',width:'120',align:'center',
            render:(createElement, params)=>{ // 动态渲染，click事件示例
            let _this = this;
            return createElement('div', {},
              [createElement('el-button', {
                props: {
                  type: 'text',
                },
                on: {
                  click() {
                    const {href} = _this.$router.resolve({
                      name: 'TenderSteps',
                      query:{ 
                        step:1,
                        id:params.row.id,
                        bidMainId:params.row.psId                        
                      }
                    })
                    window.open(href, '_blank');
                  }
                }
              }, params.row.psNo)
              ]);
          }
          },
          {label: '项目名称',key: 'psTitle',width:'250',align:'center',halign:'center'},
          {label: '采购组织',key: 'purOrgName',width:'120',align:'center'},
          {label: '应标',key: 'responseStatus',width:'60',align:'center',render:(createElement, params)=>{
            return createElement(TableIcon,{props:{
              flag: params.row.responseStatus,
              titles: [{status:0,title:'未应标'},{status:1,title:'已应标'}]
            }});
          }},
          {label: '付款凭证',key: 'bondPayStatus',width:'80',align:'center',render:(createElement, params)=>{
            return createElement(TableIcon,{props:{
              flag: params.row.bondPayStatus,
              titles: [{status:0,title:'未上传付款凭证'},{status:1,title:'已上传付款凭证'},{status:3,title:'待上传付款凭证'}]
            }});
          }}, 
          {label: '投标',key: 'quoteStatus',width:'60',align:'center',render:(createElement, params)=>{
            return createElement(TableIcon,{props:{
              flag: params.row.quoteStatus,
              titles: [{status:0,title:'未投标'},{status:1,title:'已投标'},{status:3,title:'待投标'}]
            }});
          }},         
          {label: '开标',key: 'submitCompStatus',width:'60',align:'center',render:(createElement, params)=>{
            return createElement(TableIcon,{props:{
              flag: params.row.submitCompStatus,
              titles: [{status:0,title:'未开标'},{status:1,title:'已开标'}]
            }});
          }},
          {label: '评标',key: 'evaluationStatus',width:'60',align:'center',render:(createElement, params)=>{
            return createElement(TableIcon,{props:{
              flag: params.row.evaluationStatus,
              titles: [{status:0,title:'未评标'},{status:1,title:'已评标'},{status:3,title:'技术待评'},{status:4,title:'商务待评'}]
            }});
          }},
          {label: '定标',key: 'winStatus',width:'60',align:'center',render:(createElement, params)=>{
            return createElement(TableIcon,{props:{
              flag: params.row.winStatus,
              titles: [{status:0,title:'未中标'},{status:1,title:'已中标'}]
            }});
          }},
          {label: '流标状态',key: 'flowStatus',width:'80',align:'center',render:(createElement, params)=>{
            return createElement(TableIcon,{props:{
              flag: params.row.flowStatus,
              titles: [{status:0,title:'未流标'},{status:1,title:'已流标'}]
            }});
          }},
          {label: '保证金退还',key: 'contractStatus',width:'150',align:'center',render:(createElement, params)=>{
            return createElement(TableIcon,{props:{
              flag: params.row.contractStatus,
              titles: [{status:0,title:'未生成合同'},{status:1,title:'已生成合同'}]
            }});
          }},
          {label: '发布时间',key: 'publishTime',width:'200',align:'center'},
          {label: '发布人',key: 'publishUserName',width:'150',align:'center'}
        ]
        };
    },
    created(){
      if(this.$route.query){
        this.config.crudMapping.query.data = this.$route.query;
      }
    },
    mounted(){ // VUE页面渲染之后调用的方法
      this.initData();
    },
    methods: {
      // 初始化页面数据
      initData(){

      }
    }
  }

</script>
